package testview.zhen.com.myapplication.mvvm

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent

/**
 * Create by ldr
 * on 2019/9/26 11:06.
 * jetpack组件 lifecycle
 */
class MyObserver : LifecycleObserver{

    val TAG = "MyObserver"

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun createLogic(){
        Log.d(TAG,"Lifecycle.Event.ON_CREATE")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun startLogic(){
        Log.d(TAG,"Lifecycle.Event.ON_START")

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun resumeLogic(){
        Log.d(TAG,"Lifecycle.Event.ON_RESUME")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun pauseLogic(){
        Log.d(TAG,"Lifecycle.Event.ON_PAUSE")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun stopLogic(){
        Log.d(TAG,"Lifecycle.Event.ON_STOP")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun destory(){
        Log.d(TAG,"Lifecycle.Event.ON_DESTROY")
    }

}